<?php

namespace app\modules\setting\configs\seller;

use sookie\excel\SaveExcel;
use yii\db\ActiveRecord;
use sookie\react\handlers\UrlHandler;
use yii\helpers\Json;
use app\modules\setting\models\seller\EtcOfficeProductSelected;
use sookie\bootstraps\handlers\AuthChecker;
use yii\helpers\Url;

/**
* Class TestConfig
* @package sookie\react\configs
* app\modules\setting\configs\seller\SelectedConfig 模型的配置类
*/
class SellingConfig{

    /**
    * @return array
    * 获取搜索表单配置
    */
    public static function getSearchConfig(){
    return [
            [
                "component" => "FormInput",
                "field" => "code",
                "label" => "选品ID",
                "placeholder" => "选品ID",
                "allowClear" => true,
            ],

    ];
    }

    /**
    * @return array
    * 获取表格的操作
    */
    public static function getTableActions(){
        return  [
        ];
    }

    /**
    * @return array
    * 获取表格行的操作
    * [] 表示要id, ["*"] 表示要一行记录,参数名record, ["id"] 指定需要的参数 ， selected_ids 表示需要所有选择的id
    * configParamsField 规定请求的时候带上数据行中的那些参数，只需要字段名
    */
    public static function getTableRowAction(){
        return [
            [
                "actionType" => "MODAL",
                "config" => [
                    "footer" => true,
                    "title" => "编辑",
                    "alert" => [
                        "description" => "填写以下表单修改数据模型"
                    ]
                ],
                "configUri" => UrlHandler::toAction("seller/selected","update"),
                "auth" => AuthChecker::doPermissionCheck("seller/selected","update"),
                "configParamsField" => ["id"],
                "label" => "编辑"
            ],
            [
                "actionType" => "LINK",
                "configUri" => "/admin/build/#/generate/ordinary/admin.setting.seller.pssp.index",
                "auth" => AuthChecker::doPermissionCheck("seller/selected","update"),
                "label" => "查看视频带货链接",
                "configParamsField" => ["selected_id"],
                "icon" => "setting",
                "type" => "primary",
            ],
        ];
    }

    /**
    * @return array
    * 获取表格配置
    */
    public static function getTableConfig(){
        return [
            "rowKey" => "id",
            "columns" => [
                [
                    "title" => "选品ID",
                    "dataIndex" => "code",
                    "sorter" => true,
                    "key" => "code",
                    "format" => "text",
                ],
//                [
//                    "title" => "机构",
//                    "dataIndex" => "user_id",
//                    "sorter" => true,
//                    "key" => "user_id",
//                    "format" => "text",
//                ],
//                [
//                    "title" => "商家",
//                    "dataIndex" => "seller_id",
//                    "sorter" => true,
//                    "key" => "seller_id",
//                    "format" => "text",
//                ],
                [
                    "title" => "产品",
                    "dataIndex" => "product_id",
                    "sorter" => true,
                    "key" => "product_id",
                    "format" => "raw",
                ],
                [
                    "title" => "拍摄状态",
                    "dataIndex" => "video_status",
                    "sorter" => true,
                    "key" => "video_status",
                    "format" => "text",
                ],
//                [
//                    "title" => "是否选中",
//                    "dataIndex" => "is_select",
//                    "sorter" => true,
//                    "key" => "is_select",
//                    "format" => "text",
//                ],
                [
                    "title" => "申请时间",
                    "dataIndex" => "apply_time",
                    "sorter" => true,
                    "key" => "apply_time",
                    "format" => "text",
                ],
                [
                    "title" => "发货状态",
                    "dataIndex" => "send_status",
                    "sorter" => true,
                    "key" => "send_status",
                    "format" => "text",
                ],
                [
                    "title" => "发货时间",
                    "dataIndex" => "send_time",
                    "sorter" => true,
                    "key" => "send_time",
                    "format" => "text",
                ],
                [
                    "title" => "发样数量",
                    "dataIndex" => "send_sample_num",
                    "sorter" => true,
                    "key" => "send_sample_num",
                    "format" => "text",
                ],
                [
                    "title" => "发货地址",
                    "dataIndex" => "send_sample_address_id",
                    "sorter" => true,
                    "key" => "send_sample_address_id",
                    "format" => "text",
                ],
                [
                    "title" => "发货单号",
                    "dataIndex" => "send_code",
                    "sorter" => true,
                    "key" => "send_code",
                    "format" => "text",
                ],
                [
                    "title" => "拍摄视频数量",
                    "dataIndex" => "video_num",
                    "sorter" => true,
                    "key" => "video_num",
                    "format" => "text",
                ],
                [
                    "title" => "带货账号数",
                    "dataIndex" => "tiktok_account_num",
                    "sorter" => true,
                    "key" => "tiktok_account_num",
                    "format" => "text",
                ],
            ],
            "actions" => self::getTableRowAction()
        ];
    }

    /**
    * 首页配置
    */
    public static function configIndex(){
        return [
            //搜索表单配置
            "searchConfig" => self::getSearchConfig(),
            // 操作配置 configParams 规定请求的时候带上那些参数
            "actionDivConfig" => self::getTableActions(),
            //表格配置
            "tableConfig" => self::getTableConfig(),
        ];
    }




    /**
    * @param ActiveRecord $model
    * @return array
    * 修改-表单配置
    */
    public static function configUpdate(ActiveRecord $model){
        return [
            "type" => "FORM",
            "formSubmitUri" => UrlHandler::toAction("seller/selected","update",["id" => $model->id]),
            "config" => [
                [
                    "component" => "FormInput",
                    "field" => "code",
                    "label" => "选品ID",
                    "placeholder" => "选品ID",
                    "allowClear" => true,
                    "initialValue" => $model->code,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "goods_id",
                    "label" => "ql_user_tiktok_product_goods.id",
                    "placeholder" => "ql_user_tiktok_product_goods.id",
                    "allowClear" => true,
                    "initialValue" => $model->goods_id,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "user_id",
                    "label" => "机构",
                    "placeholder" => "机构",
                    "allowClear" => true,
                    "initialValue" => $model->user_id,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "seller_id",
                    "label" => "商家",
                    "placeholder" => "商家",
                    "allowClear" => true,
                    "initialValue" => $model->seller_id,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "product_id",
                    "label" => "产品",
                    "placeholder" => "产品",
                    "allowClear" => true,
                    "initialValue" => $model->product_id,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "is_select",
                    "label" => "是否机构选中：0否，1是",
                    "placeholder" => "是否机构选中：0否，1是",
                    "allowClear" => true,
                    "initialValue" => $model->is_select,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "apply_time",
                    "label" => "申请时间",
                    "placeholder" => "申请时间",
                    "allowClear" => true,
                    "initialValue" => $model->apply_time,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "send_status",
                    "label" => "发货状态",
                    "placeholder" => "发货状态",
                    "allowClear" => true,
                    "initialValue" => $model->send_status,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "send_time",
                    "label" => "发货时间",
                    "placeholder" => "发货时间",
                    "allowClear" => true,
                    "initialValue" => $model->send_time,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "send_sample_num",
                    "label" => "发样数量",
                    "placeholder" => "发样数量",
                    "allowClear" => true,
                    "initialValue" => $model->send_sample_num,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "send_sample_address_id",
                    "label" => "发货地址",
                    "placeholder" => "发货地址",
                    "allowClear" => true,
                    "initialValue" => $model->send_sample_address_id,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "send_code",
                    "label" => "发货单号",
                    "placeholder" => "发货单号",
                    "allowClear" => true,
                    "initialValue" => $model->send_code,
                    "rules" => [],
                ],
                [
                    "component" => "FormInput",
                    "field" => "video_status",
                    "label" => "拍摄状态",
                    "placeholder" => "拍摄状态",
                    "allowClear" => true,
                    "initialValue" => $model->video_status,
                    "rules" => [],
                ],
            ],
        ];
    }


}

